package net.dgg.zz.credential.externalFunction.controller;

import net.dgg.framework.tac.utils.web.commmon.DggBaseController;
import net.dgg.iboss.base.util.datatable.DataTableUtils;
import net.dgg.iboss.base.util.datatable.domain.DataTableRequest;
import net.dgg.iboss.base.util.datatable.domain.DataTableResponse;
import net.dgg.zz.credential.externalFunction.service.ProductReservationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/zzsc/product_reservation")
public class ProductReservationController extends DggBaseController {
    @Autowired
    private ProductReservationService productReservationService;

    @ResponseBody
    @RequestMapping("get_product_reservation")
    public DataTableResponse queryDataWithPage(@RequestParam Map params, HttpServletRequest request){
        try {
            DataTableRequest r = DataTableUtils.getParam(request); //获取datatable参数
            params.put("page",r.getPage());//获取当前页
            params.put("limit",r.getLength());//获取每页条数
            List<Map> list = productReservationService.queryDataWithPage(params);
            int count = Integer.parseInt(params.get("count").toString());//总条数
            return new DataTableResponse(r.getDraw(), count, count, list, "");//返回数据
        }catch (Exception e){
            e.printStackTrace();
            return new DataTableResponse(0, 0, 0, null, "查询失败");
        }
    }
}
